import { Vec2 } from "cc";
import { BannerOptions } from "../platform/BannerOptions";
import { AdHorizontal } from "./AdHorizontal";
import { AdVertical } from "./AdVertical";
import { CustomSize } from "./CustomSize";


export class CustomOptions extends BannerOptions {

    public static New(horizontal: AdHorizontal, vertical: AdVertical, offset: Vec2, left: number, top: number): CustomOptions {
        var options = new CustomOptions();
        options.Horizontal = horizontal;
        options.Vertical = vertical;
        if (offset)
            options.Offset = offset;
        else
            options.Offset = Vec2.ZERO;
        options.Left = left;
        options.Top = top;
        return options;
    }

    public currentSize: CustomSize = CustomSize.One_One;

    /// <summary>
    /// 广告布局
    /// </summary>
    public isHorizontal: boolean = true;

    public get Width() {
        switch (this.currentSize) {
            case CustomSize.One_One:
            case CustomSize.Two_One:
            case CustomSize.Three_One:
            case CustomSize.Four_One:
            case CustomSize.Five_One:
                return 72;
            case CustomSize.One_Two:
                return 72 * 2;
            case CustomSize.One_Three:
                return 72 * 3;
            case CustomSize.One_Four:
                return 72 * 4;
            case CustomSize.One_Five:
                return 72 * 5;
            case CustomSize.Two_Five:
            case CustomSize.Three_Five:
            case CustomSize.Four_Five:
            case CustomSize.Five_Five:
                return 360;
            default:
                return 0;
        }
    }
    private headH: number = 30;
    public get Height() {
        switch (this.currentSize) {
            case CustomSize.One_One:
            case CustomSize.One_Two:
            case CustomSize.One_Three:
            case CustomSize.One_Four:
            case CustomSize.One_Five:
                return 106;
            case CustomSize.Two_One:
                return this.headH + 76 * 2;
            case CustomSize.Three_One:
                return this.headH + 76 * 3;
            case CustomSize.Four_One:
                return this.headH + 76 * 4;
            case CustomSize.Five_One:
                return this.headH + 76 * 5;

            case CustomSize.Two_Five:
                return 55 * 2 + 78;
            case CustomSize.Three_Five:
                return 55 * 3 + 78;
            case CustomSize.Four_Five:
                return 55 * 4 + 78;
            case CustomSize.Five_Five:
                return 55 * 5 + 78;
            default:
                return 0;
        }
    }

    public set Width(value) {
        this._width = value;
    }
    public set Height(value) {
        this._height = value;
    }
}